package com.nulldev.util.java.scripting.brainfuck;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;

public class BrainfuckFactory implements ScriptEngineFactory {
	static final BrainfuckFactory INSTANCE = new BrainfuckFactory();

    @Override
    public String getEngineName() {
        return "brainfuckse";
    }

    @Override
    public String getEngineVersion() {
        return "1.0";
    }

    @Override
    public List<String> getExtensions() {
        return Arrays.asList("bf", "b");
    }

    @Override
    public List<String> getMimeTypes() {
        return Collections.singletonList("text/*");
    }

    @Override
    public List<String> getNames() {
        return Collections.singletonList("bf");
    }

    @Override
    public String getLanguageName() {
        return "brainfuck";
    }

    @Override
    public String getLanguageVersion() {
        return "1.0";
    }

    @Override
    public Object getParameter(String key) {
        switch(key) {
            case ScriptEngine.ENGINE: return getEngineName();
            case ScriptEngine.ENGINE_VERSION: return getEngineVersion();
            case ScriptEngine.LANGUAGE: return getLanguageName();
            case ScriptEngine.LANGUAGE_VERSION: return getLanguageVersion();
            case ScriptEngine.NAME: return getNames().get(0);
            case "THREADING": return "STATELESS";
            default: return null;
        }
    }

    @Override
    public String getMethodCallSyntax(String obj, String m, String... args) {
        return "";
    }

    @Override
    public String getOutputStatement(String toDisplay) {
        return "";
    }

    @Override
    public String getProgram(String... statements) {
        return String.join("", statements);
    }

    @Override
    public ScriptEngine getScriptEngine() {
        return new BrainfuckEngine();
    }
}
